<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


//select count() from table where <cond>;

/**
 * Description of listview
 *
 * @author rhyamada@gmail.com
 *
 *
 *
 *
 */
class Listview_Frontend {

    function getJSON(stdClass $request) {
        if (!isset($request->id))
            throw new Exception("request->id is required");
        if (!isset($request->attrs))
            throw new Exception("request->attrs is required");

        $s = new Ldap_Backend();
        $s->open("localhost", "cn=Manager,dc=serpro,dc=gov,dc=br", "password");

        $cursor = $s->select($request->attrs)
                ->from($request->id)
                //->where("ou=SUPCD*")
                ->exec();

        $response = array();

        while (($data = $cursor->fetch()))
            array_push($response, $data);
        return $response;
    }

}

?>
